package pl.kosmowska.ewelina.server.jdo;

import java.util.Date;
import java.util.logging.Logger;
import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.NotPersistent;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Version;
import javax.jdo.annotations.VersionStrategy;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

@PersistenceCapable
@Version(strategy=VersionStrategy.VERSION_NUMBER, column="version", extensions={@Extension(vendorName="datanucleus", key="key", value="version")})
public class LoanData implements DatabaseEntity<String>{

	/**
	 * primary id
	 * transposed to web safe id (base64) for transport
	 */
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;

	/**
	 * mandatory parameter used with request factory
	 * @Version in JPA annotation
	 */
	@Persistent
	private Long version;

	/**
	 * entity owner - the person who's logged in
	 */
	@Persistent
	private Long userId; 

	/**
	 * name of the Loan
	 */

	// TODO: do zmiany
	@Persistent
	private String name;

	@Persistent
	private float value;
	
	@Persistent
	private float valueToPay;

	@Persistent
	private float percentage;

	@Persistent
	private float fee;

	@Persistent
	private float realPercentage;


	@Persistent
	private int feeChoice;
	/* 0 - nie uwzgledniaj
	 * 1 - zwieksza kwote kredytu
	 * 2-  zmniejsza kwote wyplaty
	 * 3 - oplacana osobno
	 */
	@Persistent
	private int installmentChoice;
	/* 0- r�wne
	 * 1- malejace
	 */

	@Persistent
	private int monthNumber;

	@Persistent
	private Date startDate;
	
	@Persistent
	private Date endDate;

	@Persistent
	private float valuePaid;
	
	@Persistent
	private float valueNotPaid;
	
	
	@Persistent
	private float otherPayments;

	public float getOtherPayments() {
		return otherPayments;
	}

	public void setOtherPayments(float otherPayments) {
		this.otherPayments = otherPayments;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}
	
	public float getPercentage() {
		return percentage;
	}

	public void setPercentage(float percentage) {
		this.percentage = percentage;
	}

	public float getFee() {
		return fee;
	}

	public void setFee(float fee) {
		this.fee = fee;
	}

	public float getValueToPay() {
		return valueToPay;
	}

	public void setValueToPay(float valueToPay) {
		this.valueToPay = valueToPay;
	}
	public float getRealPercentage() {
		return realPercentage;
	}

	public void setRealPercentage(float realPercentage) {
		this.realPercentage = realPercentage;
	}

	public int getFeeChoice() {
		return feeChoice;
	}

	public void setFeeChoice(int feeChoice) {
		this.feeChoice = feeChoice;
	}

	public int getInstallmentChoice() {
		return installmentChoice;
	}

	public void setInstallmentChoice(int installmentChoice) {
		this.installmentChoice = installmentChoice;
	}

	public int getMonthNumber() {
		return monthNumber;
	}

	public void setMonthNumber(int monthNumber) {
		this.monthNumber = monthNumber;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public float getValuePaid() {
		return valuePaid;
	}

	public void setValuePaid(float valuePaid) {
		this.valuePaid = valuePaid;
	}

	public float getValueNotPaid() {
		return valueNotPaid;
	}

	public void setValueNotPaid(float valueNotPaid) {
		this.valueNotPaid = valueNotPaid;
	}


	/* 0 - zwieksza kwote kredytu
	 * 1-  zmniejsza kwote wyplaty
	 * 2 - oplacana osobno
	 */

	public float getValue() {
		return value;
	}

	public void setValue(float value) {
		this.value = value;
	}


	public void setId(String id) {
		if (id == null) {
			return;
		}
		key = KeyFactory.stringToKey(id);
	}
	public String getId() {
		String id = null;
		if (key != null) {
			id = KeyFactory.keyToString(key);
		}
		return id;
	}

	public void setVersion(Long version) {
		this.version = version;
	}
	public Long getVersion() {
		if (version == null) {
			version = 0l;
		}
		return version;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}
	public Long getUserId() {
		return userId;
	}

	public void setName(String name) {
		this.name = name;
	}
	public String getName() {
		return name;
	}




}
